package com.itmiaojie.dao;

import com.alibaba.dubbo.config.annotation.Service;
import com.itmiaojie.pojo.Order;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface OrderDao {
    List<Order> findByCondition(Order order);

    void add(Order order);

    Map findById4Detail(Integer id);


    @Select("SELECT COUNT(*) FROM t_order WHERE orderDate =  #{today} ")
    Integer findOrderCountByDate(String today);
    @Select("SELECT COUNT(*) FROM t_order WHERE orderDate >=  #{thisWeekMonday} ")
    Integer findOrderCountAfterDate(String thisWeekMonday);

    @Select("SELECT COUNT(*) FROM t_order WHERE orderDate = #{today} AND orderStatus ='已到诊'")
    Integer findVisitsCountByDate(String today);
    @Select("SELECT COUNT(*) FROM t_order WHERE orderDate >= #{today} AND orderStatus ='已到诊'")
    Integer findVisitsCountAfterDate(String thisWeekMonday);
    @Select("SELECT \n" +
            "      s.name, \n" +
            "      COUNT(o.id) setmeal_count ,\n" +
            "      COUNT(o.id)/(SELECT COUNT(id) FROM t_order) proportion\n" +
            "FROM  t_order AS o,t_setmeal AS s \n" +
            "WHERE o.setmeal_id = s.id GROUP BY s.name \n" +
            "ORDER BY setmeal_count DESC LIMIT 0,4")
    List<Map> findHotSetmeal();
}
